package com.zhang.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.pojo.CustomCountBean;
import com.zhang.pojo.SaleCountBean;
import com.zhang.service.ICustomCountService;
import com.zhang.service.ISaleCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Api(tags = "销售统计控制层接口")
@RestController
@RequestMapping("saleAndCustom")
public class SaleCountController {

    @Autowired
    private ISaleCountService saleCountService;
    @Autowired
    private ICustomCountService customCountService;

    @ApiOperation("根据厂商，起始、结束日期动态查询并分页")
    @GetMapping("findByPageAndItem")
    public IPage<SaleCountBean> findByPageAndItemBySale(Integer current,
                                                  Integer pageSize,
                                                  String saleName,
                                                  LocalDate start,
                                                  LocalDate end){
       return saleCountService.findByItemAndPage(new Page<>(current,pageSize),saleName,start,end);
    }

    @ApiOperation("根据客户，起始、结束日期动态查询并分页")
    @GetMapping("findByPageAndItemByCustom")
    public IPage<CustomCountBean> findByPageAndItemByCustom(Integer current,
                                                            Integer pageSize,
                                                            String customName,
                                                            LocalDate start,
                                                            LocalDate end){
        return customCountService.findByItemAndPage(new Page<>(current,pageSize),customName,start,end);
    }
}
